package de.dlrg.wms.gui.views;

import java.util.List;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TableItem;

import de.dlrg.wms.controller.controllers.TrackController;
import de.dlrg.wms.gui.forms.generic.AbstractTableViewWithDeleteEdit;
import de.dlrg.wms.gui.views.coulmnNames.TrackColumnNames;
import de.dlrg.wms.model.Track;

import static de.dlrg.wms.gui.views.coulmnNames.TrackColumnNames.*;

public class TrackView extends AbstractTableViewWithDeleteEdit {
	private TrackController trackController;
	
	@Override
	protected void refresh() {
		this.table.clearAll();
		this.table.setItemCount(0);
		List<Track> trackList = trackController.readAll();
		for(Track track : trackList) {
			TableItem trackTableItem = new TableItem(this.table, SWT.NULL);
			
			trackTableItem.setData(track);
			trackTableItem.setText(TRACK_NO.ordinal(), "" + track.getTrackNumber());
			trackTableItem.setText(ASSIGNED_DEVICE.ordinal(), "" + track.getStopperDevice().getName());
		}
	}

	@Override
	protected void editPressed() {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void deletePressed() {
		// TODO Auto-generated method stub
		
	}

	public TrackView(Composite parent, int border,
			final TrackController trackController, final Shell shell) {
		super(parent, border);
		this.trackController = trackController;
		this.tableColumns = TrackColumnNames.class;
		this.initGUI(shell);
	}

}
